From: Jonas Jelonek Date: Sat, 13 Dec 2025 10:16:21 +0000 (+0000) Subject: realtek: pcs: add helpers for even, odd, neighbor SerDes X-Git-Url: http://git.openwrt.org/%22https:/collectd.org//%22%24PHP_SELF/%22https:/collectd.org/%22%24PHP_SELF?a=commitdiff_plain;h=232c1fb14a072ee5c3c96ead43919ab5add526dd;p=openwrt%2Fopenwrt.git realtek: pcs: add helpers for even, odd, neighbor SerDes Add dedicated helpers to get references to even, odd and neigbor SerDes if needed. This should replace the various calculations scattered throughout the code, providing a unified way to work with adjacent SerDes. Signed-off-by: Jonas Jelonek Link: https://github.com/openwrt/openwrt/pull/21146 Signed-off-by: Robert Marko --- diff --git a/target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c b/target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c index 566e79962c..435a74af7c 100644 --- a/target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c +++ b/target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c @@ -239,6 +239,27 @@ static int rtpcs_sds_modify(struct rtpcs_ctrl *ctrl, int sds, int page, int regn mask, set); } +__maybe_unused +static struct rtpcs_serdes *rtpcs_sds_get_even(struct rtpcs_serdes *sds) +{ + u32 even_sds = sds->id & ~1; + return &sds->ctrl->serdes[even_sds]; +} + +__maybe_unused +static struct rtpcs_serdes *rtpcs_sds_get_odd(struct rtpcs_serdes *sds) +{ + u32 odd_sds = sds->id | 1; + return &sds->ctrl->serdes[odd_sds]; +} + +__maybe_unused +static struct rtpcs_serdes *rtpcs_sds_get_neighbor(struct rtpcs_serdes *sds) +{ + u32 nb_sds = sds->id ^ 1; + return &sds->ctrl->serdes[nb_sds]; +} + static int rtpcs_regmap_read_bits(struct rtpcs_ctrl *ctrl, int base, int bithigh, int bitlow) { int offset = base + (bitlow / 32) * 4;